package com.four.bmm.controller;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/CheckCodeServlet")
public class CheckCodeServlet extends HttpServlet {
    //为什么我传不上啊啊啊啊啊
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String checkcode=req.getParameter("checkCode");
        HttpSession session=req.getSession();
        PrintWriter out =resp.getWriter();
        if(checkcode.equals("")||checkcode==null){
            out.print("1");
        }else{
            if(!checkcode.equalsIgnoreCase((String)session.getAttribute("randCheckCode"))){
                out.print("2");
            }else{
                out.print("3");
            }
        }
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }
}
